﻿<%@ WebHandler Language="C#" Class="ShowListEmployee" %>

using System;
using System.Web;
using System.Text;
using System.Data;
using Chenxin.Lib.Utility;
using Chenxin.Lib.Hr;
using Chenxin.Lib.Hr.BLL;

public class ShowListEmployee : AjaxHandlerBase
{

    
    /// <summary>
    /// 基本权限项
    /// </summary>
    public ShowListEmployee()
    {
        //人效修改
        htTypePermit.Add("chgnum", Constants.Permit_EfficencyChgNum);
        //导出
        htTypePermit.Add("export", Constants.Permit_EfficencyList_Export);
        htTypePermit.Add("exportall", Constants.Permit_EfficencyList_Export);
    }

    override public void RequestProcess(HttpContext context)
    {
        context.Response.AddHeader("pragma", "no-cache");
        context.Response.AddHeader("cache-control", "");
        context.Response.CacheControl = "no-cache";
        string strOp = context.Request["op"];
        string strResponse = "";
        switch (strOp.ToLower())
        {
            //查询
            case "search":
                strResponse = Search(context);
                break;
            case "getmodel":
                strResponse = GetModel(context);
                break;
            //人效修改
            case "chgnum":
                strResponse = ChgNum(context);
                break;
            case "exportall":
                ExportAll(context);
                break;
            default:
                break;
        }
        context.Response.Write(strResponse);
    }

    /// <summary>
    /// 获取实体
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    private string GetModel(HttpContext context)
    {
        try
        {
            Chenxin.Lib.Hr.Entity.t_Efficency_Employee model = null;

            model = Chenxin.Lib.Hr.DAL.t_Efficency_Employee.GetModel(new Guid(context.Request["modelid"]));

            if (model != null)
            {
                return retExecResult(Constants.ExecResult.Succ, "", model);
            }
            else
            {
                return retExecResult(Constants.ExecResult.Error, "数据不存在，获取信息失败！", "");
            }
        }
        catch (Exception ex)
        {
            return retExecResult(Constants.ExecResult.Error, ex.Message, "");
        }
    }

    //*******************************************
    //功能概要       ：人效列表
    //参数説明       ：context 请求的上下文
    //返回值説明     ：无
    //功能詳細       ：人效列表
    //作成者         ：zou.xiaochun
    //作成日         ：2010-08-18
    //*******************************************
    private string Search(HttpContext context)
    {
        try
        {
            //页码
            int strPageIndex = (string.IsNullOrEmpty(context.Request["pageindex"])) ? 1 : int.Parse(context.Request["pageindex"]) + 1;
            //页显示行数
            int strPageSize = (string.IsNullOrEmpty(context.Request["pagesize"])) ? 50 : int.Parse(context.Request["pagesize"]);
            string strPosition = context.Request["Position"];

            //查询条件
            string sqlWhere = GenerateCondition(context);

            if (strPosition == "店长" || strPosition == "区经" || strPosition == "高经")
            {
                Chenxin.Lib.Hr.BLL.t_Efficency_Employee bllEfficency = new Chenxin.Lib.Hr.BLL.t_Efficency_Employee();
                string strYearMonth = string.Empty;
                strYearMonth = GetYearMonth(context);
                System.Data.DataSet ds = bllEfficency.GetModelListByCoditions(sqlWhere, strPageIndex, strPageSize, strYearMonth);
                //总页数
                int count = (int)ds.Tables[1].Rows[0][0];
                return string.Format("{{success:'1',msg:'{0}',data:{{count:'{1}',{2}}}}}", Resources.Message.Global_Msg_SUCCESS, count, JsonHelp.Convert2Json(ds.Tables[0]));
            }
            else
            {
                Chenxin.Lib.Hr.BLL.t_Efficency_Employee bllEfficency = new Chenxin.Lib.Hr.BLL.t_Efficency_Employee();
                System.Data.DataSet ds = bllEfficency.GetEmpList(sqlWhere, strPageIndex, strPageSize);
                //总页数
                int count = (int)ds.Tables[1].Rows[0][0];
                return string.Format("{{success:'1',msg:'{0}',data:{{count:'{1}',{2}}}}}", Resources.Message.Global_Msg_SUCCESS, count, JsonHelp.Convert2Json(ds.Tables[0]));
            }
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'{0}：{1}',data:''}}", Resources.Message.Global_Err_Exception, ex.Message);
        }
    }

    public string GetYearMonth(HttpContext context)
    {
        string yearmonth = string.Empty;

        if (!string.IsNullOrEmpty(context.Request["year"]) && (!string.IsNullOrEmpty(context.Request["month"])))
        {
            yearmonth = context.Request["year"] + "." + context.Request["month"];
        }
        else
        {
            string year = System.DateTime.Now.Year.ToString();
            string month = string.Empty;
            if (System.DateTime.Now.Month.ToString().Length == 1)
            {
                month = "0" + (System.DateTime.Now.Month.ToString());
            }
            else if (System.DateTime.Now.Month.ToString().Length == 2)
            {
                month = (System.DateTime.Now.Month.ToString());
            }
            yearmonth = year + "." + month;
        }
        return yearmonth;
    }
    
    //*******************************************
    //功能概要       ：查询权限
    //参数説明       ：context 请求上下文
    //返回值説明     ：程序处理信息提示
    //功能詳細       ：生成查询条件语句
    //作成者         ：chen.yugong
    //作成日         ：2010-06-29
    //修改者         ：王玮
    //修改日         ：2010-07-13
    //*******************************************
    public string GenerateCondition(HttpContext context)
    {
        try
        {
            //获取页面查询条件
            Guid city = (string.IsNullOrEmpty(context.Request["cityid"])) ? Guid.Empty : new Guid(context.Request["cityid"]);
            Guid company = (string.IsNullOrEmpty(context.Request["companyid"])) ? Guid.Empty : new Guid(context.Request["companyid"]);
            Guid businessdistrict = (string.IsNullOrEmpty(context.Request["areaid"])) ? Guid.Empty : new Guid(context.Request["areaid"]);
            Guid departs = (string.IsNullOrEmpty(context.Request["departid"])) ? Guid.Empty : new Guid(context.Request["departid"]);
            Guid employee = (string.IsNullOrEmpty(context.Request["userid"])) ? Guid.Empty : new Guid(context.Request["userid"]);
            string strCode = context.Request["EmployeeCode"];
            string strPosition = context.Request["Position"];
            string yearmonth = string.Empty;
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            if (!string.IsNullOrEmpty(context.Request["year"]) && (!string.IsNullOrEmpty(context.Request["month"])))
            {
                yearmonth = context.Request["year"] + "." + context.Request["month"];
            }
            else
            {
                string year = System.DateTime.Now.Year.ToString();
                string month = string.Empty;
                if (System.DateTime.Now.Month.ToString().Length == 1)
                {
                    month = "0" + (System.DateTime.Now.Month.ToString());
                }
                else if (System.DateTime.Now.Month.ToString().Length == 2)
                {
                    month = (System.DateTime.Now.Month.ToString());
                }
                yearmonth = year + "." + month;
            }

            //判断级联菜单
            if (employee != Guid.Empty)
                sb.AppendFormat(" and (a.EmployeeID = '{0}') ", employee);
            else if (departs != Guid.Empty)
                sb.AppendFormat(" and (a.DepartID = '{0}')", departs);
            else if (businessdistrict != Guid.Empty)
            {
                Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo item = null;
                string strCachkey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, businessdistrict);
                Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
                item = cs.GetObject<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo>(strCachkey);
                if (!cs.Hit)
                {
                    item = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(businessdistrict);
                    if (item != null) cs.Set(strCachkey, item, DateTime.Now.AddDays(1));
                }

                if (item == null) return string.Format("{{success:'0',msg:'{0}',data:''}}", Resources.Message.Global_Err_GetBusDis);

                sb.AppendFormat(" and (a.DepartID in (select departId from Chenxin_Business.dbo.v_Hr_DepartmentInfo where DepartSrc like '{0}%'))", item.DepartSrc);
            }
            else if (company != Guid.Empty)
            {
                sb.AppendFormat(" and CompanyID = '{0}'", company);
            }
            else if (city != Guid.Empty)
            {
                sb.AppendFormat(" and CityID = '{0}'", city);
            }
            else
            {
                sb.AppendFormat(" and CompanyID = '{0}'", CurrentUserInfo.CompanyId);
            }

            //查询权限判断权限
            System.Text.StringBuilder sb1 = new System.Text.StringBuilder();
            if (CurrentUserInfo.ContainsPermit(Constants.Permit_EfficencyListSearch_All))
            {
                sb1.Append(" (1=1) ");
            }
            else if (CurrentUserInfo.ContainsPermit(Constants.Permit_EfficencyListSearch_City))
            {
                sb1.AppendFormat(" (CityID = '{0}')", CurrentUserInfo.CityId);
            }
            else if (CurrentUserInfo.ContainsPermit(Constants.Permit_EfficencyListSearch_Company))
            {
                sb1.AppendFormat(" (CompanyID = '{0}')", CurrentUserInfo.CompanyId);
            }
            else if (CurrentUserInfo.ContainsPermit(Constants.Permit_EfficencyListSearch_Depart))
            {
                sb1.Append(" (EXISTS(");
                sb1.AppendFormat("Select 1 from t_Business_EmpSetting M WHERE t_Efficency_Employee.DepartID=M.DepartId And M.Userid= '{0}'", CurrentUserInfo.UserId.ToString());
                sb1.Append(")) ");
            }
            else
            {
                sb1.AppendFormat(" (a.EmployeeID = '{0}')", CurrentUserInfo.UserId);
            }

            if (!String.IsNullOrEmpty(sb.ToString()))
            {
                sb1.Append(sb.ToString());
            }

            if (!String.IsNullOrEmpty(yearmonth))
            {
                sb1.AppendFormat(" and a.YearMonth = '{0}'", yearmonth);
            }

            if (strPosition == "店长" || strPosition == "区经" || strPosition == "高经")
            {
                sb1.Append(" and a.position in( '店长','区经','高经') ");
            }
            else
            {
                sb1.Append(" and a.position = '业务员' ");
            }

            if (!string.IsNullOrEmpty(strCode))
            {
                sb1.AppendFormat(" and a.employeeId in (select userid from Hr_UserInfo where usercode like '%{0}%') ", strCode);
            }
            return sb1.ToString();
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'{0}：{1}',data:''}}", Resources.Message.Global_Err_Exception, ex.Message);
        }
    }

    //*******************************************
    //功能概要       ：人效修改
    //参数説明       ：context 请求的上下文
    //返回值説明     ：无
    //功能詳細       ：人效修改
    //作成者         ：zou.xiaochun
    //作成日         ：2010-08-18
    //*******************************************
    private string ChgNum(HttpContext context)
    {
        //人效修改信息
        string efficency = context.Request.Params["model"];

        //人效修改业务类
        Chenxin.Lib.Hr.BLL.t_Efficency_Employee bllEfficency = new Chenxin.Lib.Hr.BLL.t_Efficency_Employee();

        //人效修改
        Chenxin.Lib.Hr.Entity.t_Efficency_Employee entEfficency =
            (Chenxin.Lib.Hr.Entity.t_Efficency_Employee)JsonHelp.Convert2Entity(efficency,
                    typeof(Chenxin.Lib.Hr.Entity.t_Efficency_Employee));

        entEfficency = CompleteEfficency(entEfficency);

        //人效修改录入
        bllEfficency.Update(entEfficency);
        return retExecResult(Constants.ExecResult.Succ, "修改成功！", "");
    }

    //*******************************************
    //功能概要       ：填充人效修改字段
    //参数説明       ：context 请求上下文
    //返回值説明     ：人效修改实体
    //功能詳細       ：填充人效修改字段
    //作成者         ：zou.xiaochun
    //作成日         ：2010-08-18
    //*******************************************
    private Chenxin.Lib.Hr.Entity.t_Efficency_Employee CompleteEfficency(Chenxin.Lib.Hr.Entity.t_Efficency_Employee entEfficency)
    {
        Chenxin.Lib.Hr.BLL.t_Efficency_Employee bllEfficency = new Chenxin.Lib.Hr.BLL.t_Efficency_Employee();
        Chenxin.Lib.Hr.Entity.t_Efficency_Employee entOldEfficency = bllEfficency.GetModel(new Guid(entEfficency.RecordID.ToString()));

        if (entOldEfficency != null)
        {
            entEfficency.RecordID = entOldEfficency.RecordID;
            entEfficency.CityID = entOldEfficency.CityID;
            entEfficency.CompanyID = entOldEfficency.CompanyID;
            entEfficency.businessdistrictID = entOldEfficency.businessdistrictID;
            entEfficency.DepartID = entOldEfficency.DepartID;
            entEfficency.EmployeeID = entOldEfficency.EmployeeID;
        }
        return entEfficency;
    }

    //导出全部的方法
    private void ExportAll(HttpContext context)
    {
        //获取页面查询条件
        Guid city = (string.IsNullOrEmpty(context.Request["cityid"])) ? Guid.Empty : new Guid(context.Request["cityid"]);
        Guid company = (string.IsNullOrEmpty(context.Request["companyid"])) ? Guid.Empty : new Guid(context.Request["companyid"]);
        Guid businessdistrict = (string.IsNullOrEmpty(context.Request["areaid"])) ? Guid.Empty : new Guid(context.Request["areaid"]);
        Guid departs = (string.IsNullOrEmpty(context.Request["departid"])) ? Guid.Empty : new Guid(context.Request["departid"]);
        Guid employee = (string.IsNullOrEmpty(context.Request["userid"])) ? Guid.Empty : new Guid(context.Request["userid"]);
        string strCode = context.Request["EmployeeCode"];
        string strPosition = context.Request["Position"];
        string yearmonth = string.Empty;
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        if (!string.IsNullOrEmpty(context.Request["year"]) && (!string.IsNullOrEmpty(context.Request["month"])))
        {
            yearmonth = context.Request["year"] + "." + context.Request["month"];
        }
        else
        {
            string year = System.DateTime.Now.Year.ToString();
            string month = string.Empty;
            if (System.DateTime.Now.Month.ToString().Length == 1)
            {
                month = "0" + (System.DateTime.Now.Month.ToString());
            }
            else if (System.DateTime.Now.Month.ToString().Length == 2)
            {
                month = (System.DateTime.Now.Month.ToString());
            }
            yearmonth = year + "." + month;
        }

        //判断级联菜单
        if (employee != Guid.Empty)
            sb.AppendFormat(" and (a.EmployeeID = '{0}') ", employee);
        else if (departs != Guid.Empty)
            sb.AppendFormat(" and (a.DepartID = '{0}')", departs);
        else if (businessdistrict != Guid.Empty)
        {
            Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo item = null;
            string strCachkey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, businessdistrict);
            Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            item = cs.GetObject<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo>(strCachkey);
            if (!cs.Hit)
            {
                item = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(businessdistrict);
                if (item != null) cs.Set(strCachkey, item, DateTime.Now.AddDays(1));
            }

            //if (item == null) return string.Format("{{success:'0',msg:'{0}',data:''}}", Resources.Message.Global_Err_GetBusDis);

            sb.AppendFormat(" and (a.DepartID in (select departId from Chenxin_Business.dbo.v_Hr_DepartmentInfo where DepartSrc like '{0}%'))", item.DepartSrc);
        }
        else if (company != Guid.Empty)
        {
            sb.AppendFormat(" and CompanyID = '{0}'", company);
        }
        else if (city != Guid.Empty)
        {
            sb.AppendFormat(" and CityID = '{0}'", city);
        }
        else
        {
            sb.AppendFormat(" and CompanyID = '{0}'", CurrentUserInfo.CompanyId);
        }

        //查询权限判断权限
        System.Text.StringBuilder sb1 = new System.Text.StringBuilder();
        if (CurrentUserInfo.ContainsPermit(Constants.Permit_LitigationSearch_All))
        {
            sb1.Append(" (1=1) ");
        }
        else if (CurrentUserInfo.ContainsPermit(Constants.Permit_LitigationSearch_City))
        {
            sb1.AppendFormat(" (CityID = '{0}')", CurrentUserInfo.CityId);
        }
        else if (CurrentUserInfo.ContainsPermit(Constants.Permit_LitigationSearch_Company))
        {
            sb1.AppendFormat(" (CompanyID = '{0}')", CurrentUserInfo.CompanyId);
        }
        else if (CurrentUserInfo.ContainsPermit(Constants.Permit_LitigationSearch_Depart))
        {
            sb1.Append(" (EXISTS(");
            sb1.AppendFormat("Select 1 from t_Business_EmpSetting M WHERE t_Efficency_Employee.DepartID=M.DepartId And M.Userid= '{0}'", CurrentUserInfo.UserId.ToString());
            sb1.Append(")) ");
        }
        else
        {
            sb1.AppendFormat(" (a.EmployeeID = '{0}')", CurrentUserInfo.UserId);
        }

        if (!String.IsNullOrEmpty(sb.ToString()))
        {
            sb1.Append(sb.ToString());
        }

        if (!String.IsNullOrEmpty(yearmonth))
        {
            sb1.AppendFormat(" and a.YearMonth = '{0}'", yearmonth);
        }

        if (strPosition == "店长" || strPosition == "区经" || strPosition == "高经")
        {
            sb1.Append(" and a.position in( '店长','区经','高经') ");
        }
        else
        {
            sb1.Append(" and a.position = '业务员' ");
        }

        if (!string.IsNullOrEmpty(strCode))
        {
            sb1.AppendFormat(" and a.employeeId in (select userid from Hr_UserInfo where usercode like '%{0}%') ", strCode);
        }

        //条件
        string strWhere = sb1.ToString();
        //查询字段
        StringBuilder sbTableFieldList = new StringBuilder();
        //所要查询的表名
        StringBuilder TableName = new StringBuilder();
        //集计
        string GroupField = string.Empty;
        //排序
        string strOrderField = string.Empty;
        
        if (strPosition == "店长" || strPosition == "区经" || strPosition == "高经")
        {
            sbTableFieldList.Append("a.RecordId,a.City,a.Company,a.Businessdistrict,a.Departs,(select UserCode from dbo.Hr_UserInfo WHERE UserId = a.EmployeeId) as EmployeeCode,a.Employee,a.Position,dateadd(dd,1,a.BeginTime) as BeginTime,dateadd(dd,0,a.EndTime) as EndTime," +
                                "a.ChangType,a.TransType,a.PeopleNum,a.YearMonth,cast((a.PeopleNum*b.PeopleNum)as decimal(5,2)) as TotalNum");
            TableName.AppendFormat(" (select RecordId,CityID,City,CompanyID,Company,BusinessdistrictID,Businessdistrict,DepartID,Departs,EmployeeID,Employee,PeopleNum,Position,BeginTime,EndTime,ChangType,TransType,YearMonth " +
                            "from t_Efficency_Employee where position in ('店长','区经','高经') and YearMonth = '{0}' " +
                            "group by RecordId,CityID,City,CompanyID,Company,BusinessdistrictID,Businessdistrict,DepartID,Departs,EmployeeID,Employee,PeopleNum,Position,BeginTime,EndTime,ChangType,TransType,YearMonth)a " +
                            "inner join (select c.DepartID,cast(sum(PeopleNum)as decimal(5,2)) as PeopleNum,c.YearMonth from " +
                            "(select DepartID,EmployeeID,PeopleNum,YearMonth from t_Efficency_Employee where position='业务员' and YearMonth = '{1}' " +
                            "group by DepartID,EmployeeID,PeopleNum,YearMonth)c group by c.DepartID,c.YearMonth)b on a.DepartID = b.DepartID ", yearmonth, yearmonth);
            GroupField = " a.RecordId,a.City,a.Company,a.Businessdistrict,a.Departs,a.EmployeeId,a.Employee,a.Position,a.BeginTime,a.EndTime,a.ChangType,a.TransType,a.PeopleNum,a.YearMonth,b.PeopleNum ";
            strOrderField = " Businessdistrict,Departs,Employee";
        }
        else
        {
            sbTableFieldList.Append("a.RecordId,a.City,a.Company,a.Businessdistrict,a.Departs,(select UserCode from dbo.Hr_UserInfo WHERE UserId = a.EmployeeId) as EmployeeCode,a.Employee,a.Position,dateadd(dd,1,a.BeginTime) as BeginTime,dateadd(dd,0,a.EndTime) as EndTime,a.ChangType,a.TransType,a.PeopleNum,a.YearMonth");
            TableName.AppendFormat("t_Efficency_Employee a ");
            GroupField = " a.RecordId,a.City,a.Company,a.Businessdistrict,a.Departs,a.EmployeeId,a.Employee,a.Position,a.BeginTime,a.EndTime,a.ChangType,a.TransType,a.PeopleNum,a.YearMonth ";
            strOrderField = " Businessdistrict,Departs,Employee";
        }

        string strSql = "select " + sbTableFieldList.ToString() + " from " + TableName + " where " + strWhere + " group by " + GroupField + " order by " + strOrderField;
        //根据sql执行查询
        DataSet ds = Chenxin.Lib.Hr.DAL.t_Efficency_Employee.GetExportList(strSql);
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            string strYearMonth = ds.Tables[0].Rows[i]["YearMonth"].ToString();
            ds.Tables[0].Rows[i]["YearMonth"] = strYearMonth.Substring(0, 4).ToString() + "年" + strYearMonth.Substring(5, 2).ToString() + "月";
        }
        string strHTML = GetHtml(ds.Tables[0]);

        ExportByServce(context, strHTML);
    }

    //导出全部的HTML
    private string GetHtml(DataTable dt)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<table class=\"tabsorternew table_archive\"><tr>");
        sb.Append("<th style=\"width:80px;\" >城市</th>");
        sb.Append("<th style=\"width:80px;\" >公司</th>");
        sb.Append("<th style=\"width:120px;\" >商圈</th>");
        sb.Append("<th style=\"width:130px;\" >部门</th>");
        sb.Append("<th style=\"width:100px;\" >工号</th>");
        sb.Append("<th style=\"width:80px;\" >姓名</th>");
        sb.Append("<th style=\"width:80px;\" >职务</th>");
        sb.Append("<th style=\"width:80px;\" >开始时间</th>");
        sb.Append("<th style=\"width:80px;\" >结束时间</th>");
        sb.Append("<th style=\"width:80px;\" >变动类型</th>");
        sb.Append("<th style=\"width:80px;\" >变动名称</th>");
        sb.Append("<th style=\"width:40px;\" >人数</th>");
        sb.Append("<th style=\"width:80px;\" >年月</th></tr>");

        foreach (System.Data.DataRow dr in dt.Rows)
        {
            sb.Append("<tr>");
            sb.AppendFormat("<td>{0}</td>", DatasetHelper.GetValue(dr, "City", ""));
            sb.AppendFormat("<td>{0}</td>", DatasetHelper.GetValue(dr, "Company", ""));
            sb.AppendFormat("<td>{0}</td>", DatasetHelper.GetValue(dr, "Businessdistrict", ""));
            sb.AppendFormat("<td>{0}</td>", DatasetHelper.GetValue(dr, "Departs", ""));
            sb.AppendFormat("<td>{0}</td>", DatasetHelper.GetValue(dr, "EmployeeCode", ""));
            sb.AppendFormat("<td>{0}</td>", DatasetHelper.GetValue(dr, "Employee", ""));
            sb.AppendFormat("<td>{0}</td>", DatasetHelper.GetValue(dr, "Position", ""));
            sb.AppendFormat("<td>{0}</td>", DatasetHelper.GetValue(dr, "BeginTime", ""));
            sb.AppendFormat("<td>{0}</td>", DatasetHelper.GetValue(dr, "EndTime", ""));
            sb.AppendFormat("<td>{0}</td>", DatasetHelper.GetValue(dr, "ChangType", ""));
            sb.AppendFormat("<td>{0}</td>", DatasetHelper.GetValue(dr, "TransType", ""));
            sb.AppendFormat("<td>{0}</td>", DatasetHelper.GetValue(dr, "PeopleNum", ""));
            sb.AppendFormat("<td>{0}</td></tr>", DatasetHelper.GetValue(dr, "YearMonth", ""));
        }
        return sb.ToString();
    }
}